﻿using System.Text.Json;
using System.Text.Json.Serialization;

namespace Grow.Json.Text.Parse
{
    public class DecimalParse : JsonConverter<decimal>
    {
        public override decimal Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            bool flag = reader.TryGetDecimal(out decimal value);
            return flag == true ? value : default;
        }

        public override void Write(Utf8JsonWriter writer, decimal value, JsonSerializerOptions options)
        {
            writer.WriteNumberValue(value);
        }
    }
}
